﻿
@{
    ViewData["Title"] = "AuthorizeIndex";
    Layout = "~/Views/Share/_Layout_Tree.cshtml";
}

<script>
    var keyValue = $.request("ids");
    $(function () {
        if (!!keyValue) {
            $("#permissionTree").treeview({
                height: 280,
                showcheck: true,
                url: "/Role/GetPermissionTree",
                param: { ids: keyValue }
            });
        }
    });
    function submitForm() {
        var postData = $("#form1").formSerialize();
        postData["permissionIds"] = String($("#permissionTree").getCheckedNodes());

        if (postData !=undefined) {
            $.loading(true, "正在提交数据");
            window.setTimeout(function () {
                $.ajax({
                    url: "/Role/RoleAuthorize?ids=" + keyValue,
                    data: postData,
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        $.loading(false);

                        if (data.errorMsg) {
                            top.layer.msg(data.errorMsg, { icon: 2 });
                        }
                        else {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            var msgs = (data.okMsg);
                            top.layer.msg(msgs, { icon: 1 });
                            parent.layer.close(index);
                        }

                    },
                    error: function () {
                        $.loading(false);

                    },
                    complete: function () {
                        $.loading(false);
                    }
                });

            }, 500);
        }
    }

</script>
<div style="margin-right:30px;padding-top:10px;">
    <form id="form1" class="form-horizontal">
        <div id="permissionTree"></div>
    </form>
</div>

